package com.auz.datagenerator.guiconnector;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * The connector between the core connector and the GUI.
 * @author Aurelien Bonnel
 */
public class GUIConnector extends JFrame implements Runnable {

	private static final long serialVersionUID = -7507233606755180013L;
	
	private int count = 0;

	/**
	 * Constructor.
	 */
	public GUIConnector() {
		super("Data generator");
		setLayout(new BorderLayout());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	/**
	 * Add a panel
	 * @param panel
	 */
	public void addPanel(JPanel panel) {
		count++;
		add(panel, ((count == 1) ? BorderLayout.NORTH : 
			(count == 2) ? BorderLayout.CENTER : BorderLayout.SOUTH));
		pack();
	}

	/**
	 * Runs the panel in a separate thread
	 */
	public void run() {
		setVisible(true);
	}
	
}
